package spatialmarketplace.cem.dao;

import java.util.List;
import spatialmarketplace.cem.model.Resource;
import spatialmarketplace.cem.model.Group;

/**
 * Resource Database Access Object: 
 * Declare all functions of resource to interact(insert, update, view) with database
 * 
 * @author Camela 
 * @implementation Hung
 */
public interface ResourceDao {
    /**
     * Get all resources in database and put all of them to a List
     * @return List of Resources
     */
    public List<Resource> read();
    /**
     * Access to database and get a resource data based on Id.
     * @param ResourceId
     * @return Resource information
     */
    public Resource read_Resource(Integer ResourceId);
    /**
     * Save or update resource to database
     * @param resource
     */
    public void save(Resource resource);
    /**
     * Search all resources based on keywords
     * @param keywords string of keywords
     * @return
     */
    public List<Resource> search(String keywords);
    /**
     * Update counter's number to database. It depends on which user and which resource
     * @param resourceId Resource ID
     * @param likeCounter Number of liked people
     * @param userId User ID
     */
    public void setLikesCounter(Integer resourceId,Integer likeCounter,Integer userId);
    /**
     * Check user liked resource or not
     * @param resourceId Resource ID
     * @param userId User ID
     * @return yes or no
     */
    public Boolean getLiked(Integer resourceId,Integer userId);
    /**
     * Check user voted resource or not
     * @param resourceId
     * @param userId
     * @return 
     */
    public Boolean getVoted(Integer resourceId,Integer userId);
    /**
     * Update Rating to Resource based on voting of user
     * @param resourceId Resource ID
     * @param rating Rating's value
     */
    public void setRating(Integer resourceId,Float rating);
    /**
     * Get all groups which are shared the resource
     * @param resourceId Resource ID
     * @return List of all sharing groups
     */
    public List<Group> listGroupsSharing(Integer resourceId);
    /**
     * Get all groups which are not shared the resource
     * @param resourceId Resource ID
     * @return List of all unsharing groups
     */
    public List<Group> listGroupsUnSharing(Integer resourceId,Integer userId);
    /**
     * In case of no resource selected, system will display the default resource (exception happen)
     * @return Resource ID
     */
    public Integer getDefaultResource();
    
    /**
     * Assign which groups are shared the resource and update this information to database
     *  
     * @param groupId Group ID
     * @param resourceId Resource ID
     */
    public void insertGroupShareResource(Integer groupId,Integer resourceId);
}




